<template>
	<view class="container">
		<view class="header">
			<view class="headimg"><image src="http://download.qiyedaishu.com/common/zhifa.png" mode="aspectFit"/></view>
			<view class="info">
				<view class="realname">{{Admin.RealName}}</view>
				<view class="unit">{{Admin.DepartName}}</view>
			</view>
		</view>
		<view class="square">
			<view class="line border-tb" @click="MyInfo()">
				<view class="name">个人资料</view><view class="arrow"></view>
			</view>
			<view class="line border-b" @click="UpdatePwd()">
				<view class="name">修改密码</view><view class="arrow"></view>
			</view>
			<view class="line border-b" @click="ShowSheet()">
				<view class="name">当前系统</view><view class="value" :class="CaseType==0?'red':''">{{SysName}}{{SysList.length>1?" (点击切换)":""}}</view><view class="arrow"></view>
			</view>
			<view class="line border-b">
				<view class="name">版本号</view><view class="value">V{{Versions}}.{{WgtCodes}}</view><view class="arrow"></view>
			</view>
			<view class="line border-b" @click="Sets()">
				<view class="name">设置</view><view class="arrow"></view>
			</view>
		</view>
		<uni-popup ref="popup" type="bottom" backgroundColor="#ffffff">
			<view class="sheetmenu border-b" @click="GoSys(model.CaseType, index)" v-for="(model,index) in SysList">{{model.SysName}}</view>
			<view class="sheetmenu" @click="Cancel">取消</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				Versions:'',
				WgtCodes:'',
				SysName:'',
				SysList:[],
				IsLoad:false,
				CaseType:0,
				Admin:{}
			};
		},
		onPullDownRefresh() {
			this.Find_AdminInfo();
		},
		onLoad() {
			// #ifdef APP
			this.Get_Version();
			// #endif
			// #ifdef H5
			this.Versions=this.Version;
			this.WgtCodes=this.WgtCode;
			// #endif
			// #ifdef MP-WEIXIN
			this.Versions=this.Version;
			this.WgtCodes=this.WgtCode;
			// #endif
		},
		onShow() {
			this.Find_AdminInfo();
		},
		methods:{
			ShowSheet(){
				if(this.SysList.length>1){
					this.$refs.popup.open();
				}
			},
			Cancel(){
				this.$refs.popup.close();
			},
			GoSys(CaseType,Index){
				this.Cancel();
				this.SysName=this.SysList[Index].SysName;
				uni.setStorageSync("IsLoad", false);
				uni.setStorageSync("CaseType", CaseType);
				uni.switchTab({
					url:'/pages/index/index'
				})
			},
			MyInfo(){
				uni.navigateTo({
					url:'/pages/my/myinfo'
				})
			},
			Sets(){
				uni.navigateTo({
					url:'/pages/my/set'
				})
			},
			UpdatePwd(){
				uni.navigateTo({
					url:"/pages/my/updatepwd"
				})
			},
			Find_AdminInfo(){
				var data = {};
				data.Act="Find_AdminInfo";
				data.CaseType = uni.getStorageSync("CaseType") || 0;
				if(!this.IsLoad){this.Util.Loading("请稍候...");}
				this.Util.Post(data, json=>{
					//console.log(json);
					uni.stopPullDownRefresh();
					this.Util.HideLoading();
					if(json.State){
						this.Admin=json.Data.Admin;
						this.SysName=json.Data.SysName;
						this.SysList=json.Data.SysList;
						this.IsLoad=true;
						this.CaseType=json.Data.CaseType;
						uni.setStorageSync("CaseType", json.Data.CaseType);
					}
				});
			},
			Get_Version(){
				plus.runtime.getProperty(plus.runtime.appid,(wgtinfo)=>{
					this.Versions=wgtinfo.version;
					this.WgtCodes=this.WgtCode;
				});
			}
		}
	}
</script>

<style lang="scss">
	.container{width:100%; overflow: hidden;
		.header{width:100%; height:240rpx; z-index:0;  padding-top:50rpx; display: flex; flex-direction: row; background-image: url(../../static/backbg.png); background-size: 100% 100%; background-repeat: no-repeat;
			.headimg{width:120rpx; height:120rpx; margin-left:50rpx;
				image{width:120rpx; height:120rpx; border:5rpx solid #ffffff; border-radius:50%; overflow:hidden;}
			}
			.info{flex:1; color:#ffffff; font-size:40rpx; 
				.realname{width:100%; height:60rpx; line-height: 60rpx; margin-left:30rpx; }
				.unit{width:100%; height:44rpx; line-height: 44rpx; padding-top:10rpx; margin-left:30rpx; font-size:34rpx;}
			}
		} 
		.square{padding-top:120rpx;
			.line{width:100%; height:100rpx; line-height: 100rpx; display: flex; flex-direction: row; background-color: #ffffff;
				.name{flex:1; padding-left:30rpx; font-size:36rpx;}
				.value{width:auto; height:100rpx; line-height: 100rpx; color:#bababa;}
				.arrow{width:60rpx; height:100rpx; background-image: url(../../static/arrow.png); background-position: center center; background-repeat: no-repeat; background-size: 30rpx;}
			}
			.line:active{background-color: #f6f6f6;}
		}
		.btn{position: absolute; left:50rpx; bottom:80rpx; width:650rpx; height:90rpx; line-height: 90rpx; border-radius:20rpx; font-size:33rpx; background-color: #e4e4e4; color:#ffffff; text-align: center; color:#868787;}
	}
</style>
